﻿@using DevExpress.Web.Mvc.UI;
@using System.Web.UI.WebControls;
@Html.DevExpress().GridView(gridSettings =>
    {
        gridSettings.Name = "UserList";
        gridSettings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
        gridSettings.CallbackRouteValues = new { Controller = "User", Action = "List" };
        gridSettings.Settings.UseFixedTableLayout = true;
        gridSettings.SettingsBehavior.ColumnResizeMode = DevExpress.Web.ASPxGridView.ColumnResizeMode.NextColumn;
        gridSettings.Columns.Add(columnSettings =>
        {
            columnSettings.Caption = "Nom Utilisateur";
            columnSettings.FieldName = "UserName";
            columnSettings.Settings.AutoFilterCondition = DevExpress.Web.ASPxGridView.AutoFilterCondition.Contains;
        });
        gridSettings.Columns.Add(columnSettings =>
        {
            columnSettings.Caption = "";
            columnSettings.Width = Unit.Percentage(20);
            columnSettings.SetDataItemTemplateContent(c =>
            {
                ViewContext.Writer.Write(Html.ActionLink("Modifier", "Edit", "User", new { id = DataBinder.Eval(c.DataItem, "UserId")}, null).ToHtmlString());
                ViewContext.Writer.Write(" | ");
                ViewContext.Writer.Write(Html.ActionLink("Détail", "Details", "User", new { id = DataBinder.Eval(c.DataItem, "UserId") }, null).ToHtmlString());
                ViewContext.Writer.Write(" | ");
                ViewContext.Writer.Write(Html.ActionLink("Supprimer", "Delete", "User", new { id = DataBinder.Eval(c.DataItem, "UserId") }, null).ToHtmlString());
            });

        });
    }).Bind(Model).GetHtml()
    
